package hsp.admin.config;

import hsp.admin.interceptor.UserIdInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class LoginConfig implements WebMvcConfigurer {

    @Bean
    public UserIdInterceptor getUserIdInterceptor(){return new UserIdInterceptor();}

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(getUserIdInterceptor());
        interceptorRegistration
            .addPathPatterns("/**")
            .excludePathPatterns("/base/login")
            .excludePathPatterns("/base/logout/**")
            .excludePathPatterns("/swagger-ui/**")
            .excludePathPatterns("/v3/api-docs/**");
    }
}
